<?php

require_once 'common/conn.php';

$usercode = $_GET['usercode'];
$score = $_GET['score'];

$result = array();
$db = new DBC();

$sql = "INSERT INTO t_parent_teacher_score(deviceid,score,gainDate,type) VALUES((SELECT deviceid FROM t_device WHERE devicecode = '" . $usercode . "')," . $score . ",now(),1)";
$id = $db->insertId($sql);
if ($id > 0) {
    $result['errorMsg'] = true;
    $result['id'] = $id;
} else {
    $result['errorMsg'] = false;
}
echo json_decode($result);
?>
